#ifndef __POPUP_DATABASE_UI_HPP__
#define __POPUP_DATABASE_UI_HPP__

#include <string>
#include <PopupLibTypes.hpp>

namespace Popup
{
  struct DatabaseUI
  {
    virtual ~DatabaseUI() {}

    struct StatisticItemUpdateResult {

      StatisticItemUpdateResult()
        : newItemValue(0), isNewRecord(false),
          previousRecordman(0), previousRecordValue(0) {}

      unsigned int  newItemValue;
      bool isNewRecord;
      UserID previousRecordman;
      unsigned int  previousRecordValue;
    };

    virtual bool getAllUsers(UserLoginMap & p_users) = 0;

    virtual ConnectionEcode newUser(const std::string & p_login,
                                    const std::string & p_password,
                                    const std::string & p_nickname,
                                    const std::string & p_avatar,
                                    User **p_user,
                                    std::string & p_message) = 0;

    //! Tells if a user connection is allowed or not.
    //!
    //! \param[in]  p_login
    //! \param[in]  p_password
    //! \param[out] p_errMessage
    //!
    //! \return True if the user connection is allowed.
    //!
    virtual bool authenticate(const std::string & p_login,
                              const std::string & p_password,
                              std::string & p_message) = 0;

    virtual bool updateNickname(User *p_user,
                                const std::string & p_newNickname,
                                std::string & p_message) = 0;

    virtual bool updateAvatar(User *p_user,
                              const std::string & p_newAvatar,
                              std::string & p_message) = 0;

    virtual bool updateUserRates(UserID p_userID,
                                 UserRateItem p_itemKey,
                                 StatisticItemUpdateResult & p_updateResult,
                                 std::string & p_message) = 0;

    virtual bool getUserStatitics(UserID p_userID,
                                  UserStatistics & p_stats,
                                  std::string & p_message) = 0;
  };
}

#endif // __POPUP_DATABASE_UI_HPP__
